<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAppUsersTable extends Migration
{
    const TABLE = 'app_users';
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        !Schema::hasTable(self::TABLE) && Schema::create(self::TABLE, function (Blueprint $table) {
            $table->uuid('id')->primary();
            $table->string('name', 50)->comment('名称');
            $table->string('phone', 20)->unique()->comment('手机号码');
            $table->string('avatar')->default('')->comment('头像');
            $table->string('member_card')->default('')->comment('卡号');
            $table->dateTime('login_at')->nullable()->comment('登录时间');
            $table->string('wx_openid', 50)->default('')->comment('微信公众号标识');
            $table->string('wmp_openid', 50)->default('')->comment('微信小程序标识');
            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("alter table `".self::TABLE."` comment '用户';");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists(self::TABLE);
    }
}
